package com.chainyoung.component_tmtrade.ui.activity;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.chainyoung.common.base.BaseActivity;
import com.chainyoung.common.base.WebViewActvity;
import com.chainyoung.common.di.AppComponent;
import com.chainyoung.component_tmtrade.bean.Ad;
import com.chainyoung.component_tmtrade.di.component.DaggerTradeFiatCurrencyActivityComponent;
import com.chainyoung.component_tmtrade.di.module.TradeFiatCurrencyActivityModule;
import com.chainyoung.component_tmtrade.ui.mvp.contract.AboutFiatCurrencyContact;
import com.chainyoung.component_tmtrade.ui.mvp.presenter.AboutFiatCurrencyPresenter;

import javax.inject.Inject;

import static com.chainyoung.router.RouterConstants.PATH_ABOUT_FIAT;

@Route(path = PATH_ABOUT_FIAT)
public class AboutFiatCurrencyActivity extends WebViewActvity<AboutFiatCurrencyPresenter> implements AboutFiatCurrencyContact.View {


    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerTradeFiatCurrencyActivityComponent.builder()
                .appComponent(appComponent)
                .tradeFiatCurrencyActivityModule(new TradeFiatCurrencyActivityModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initUI() {
        super.initUI();
        mWebView.getSettings().setDefaultFontSize(40);
    }

    @Override
    protected void initData() {
        mPresenter.getFiatCurrencyNotice();
    }

    @Override
    public void showFiatCurrencyNotice(Ad data) {
        setCurrentTitle(data.getTitle().length() > 10 ? data.getTitle().substring(0, 10) + "..." : data.getTitle());
        mWebView.loadDataWithBaseURL(null, data.getContent(), "text/html", "UTF-8", null);

    }

    @Override
    protected int getLayoutId() {
        return super.getLayoutId();
    }
}
